package com.victualler.core.common.enums;


import com.victualler.core.common.exception.CoreRuntimeException;

public enum ChecKDataErrorEnum {
    Success("0000", "执行成功"),
    NULL_ERROR("0001", "非空校验出错"),
    CONFIG_ERROR("0002", "系统配置出错"),
    DATA_ERROR("0003", "数据缺失"),
    RUN_ERROR("0004", "运行时出错"),
    REPEAT_ERROR("0005", "重复请求,数据重复"),
    CHECK_ERROR("0006", "校验不通过"),
    CALL_ERROR("0007", "接口调用出错"),
    TRANSLATE_ERROR("0008", "解析转换出错"),
    RISKLEVEL_ERROR("0009", "险位未做风险评估"), ;

    private String key;
    private String value;

    private ChecKDataErrorEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String getValue(String key) {
        ChecKDataErrorEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ChecKDataErrorEnum e = var1[var3];
            if (e.getKey().equals(key)) {
                return e.value;
            }
        }
        return null;
    }

    /**
     * @Aouthor Guoshichang
     * @Date 14:26 on 2018/6/4.
     * @param checKDataErrorEnum
     * @param appendErrorCause 追加原因
     * @Function
     */
    public static CoreRuntimeException createException(ChecKDataErrorEnum checKDataErrorEnum, String appendErrorCause) {
        return new CoreRuntimeException(checKDataErrorEnum.getKey(),checKDataErrorEnum.getValue()+" cause: "+appendErrorCause);
    }



    /**
     * @Aouthor Guoshichang
     * @Date 14:26 on 2018/6/4.
     * @param checKDataErrorEnum
     * @Function
     */
    public static CoreRuntimeException createException(ChecKDataErrorEnum checKDataErrorEnum) {
        return new CoreRuntimeException(checKDataErrorEnum.getKey(),checKDataErrorEnum.getValue());
    }



    public String getValue() {
        return this.value;
    }

    public String getKey() {
        return this.key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
